package com.tws.pctask.controller;

import com.tws.common.model.ResponseWrapper;
import com.tws.pctask.model.departmentManageModel.*;
import com.tws.pctask.service.DepartmentManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Description： 部门管理控制层
 * @Author: wbf
 * @Date: 2022/1/26 21:47
 */
@CrossOrigin
@RestController
@RequestMapping("systemFunction/basicSetting/departmentManage")
public class DepartmentManageController {
    @Autowired
    private DepartmentManageService departmentManageService;
    /**
     * 4.1获取部门列表
     * @param param 参数类
     * @return 部门列表
     */
    @GetMapping("getDepartmentList")
    public ResponseWrapper getDepartmentList(@Validated GetDepartmentListParam param){
        return departmentManageService.getDepartmentList(param);
    }

    /**
     * 4.2新增或修改部门
     * @param param 修改参数
     * @return 是否成功
     */
    @PostMapping("addOrUpdateDepartment")
    public ResponseWrapper addOrUpdateDepartment(@Validated @RequestBody AddOrUpdateDepartmentParam param){
        return departmentManageService.addOrUpdateDepartment(param);
    }

    /**
     * 4.3检查部门名称是否重复
     * @param param 部门名称
     * @return 是否重复
     */
    @GetMapping("checkDepartmentName")
    public ResponseWrapper checkDepartmentName(CheckDepartmentNameParam param){
        return departmentManageService.checkDepartmentName(param);
    }

    /**
     * 4.4获取部门信息
     * @param param 部门id
     * @return 部门信息
     */
    @GetMapping("getUserInfo")
    public ResponseWrapper getUserInfo(GetDepartmentInfoParam param){
        return departmentManageService.getUserInfo(param);
    }

    /**
     * 4.5删除部门
     * @param param 部门id
     * @return 删除结果
     */
    @PostMapping("delDepartment")
    public ResponseWrapper delDepartment(@Validated @RequestBody DelDepartmentParam param){
        return departmentManageService.delDepartment(param);
    }
}
